﻿/* DotNetHoldem 
 * .Net Solution that allows to use OpenHoldem with .Net logic
 * Author: Óscar Andreu
 * oesido at gmail dot com
 * Licensed under GPLv3 - 2012
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetBotLogic.Enums;
using DotNetBotLogic.Classes.Log;
using DotNetBotLogic.Controllers;

namespace DotNetBotLogic.Classes.BetRoundClasses
{
    internal class BetRoundBase
    {
        #region Variables

        protected double actionResult;
        protected BaseController ctrl;

        protected PositionsNL6 dealPosition;

        #endregion

        #region Constructor

        internal BetRoundBase(BaseController ctrl)
        {
            this.ctrl = ctrl;
        }

        #endregion

        /// <summary>
        /// Must be overriden to get the value for the action
        /// </summary>
        /// <returns></returns>
        internal virtual double getAction() { return 0; }


        /// <summary>
        /// In the first round, the BB and SB count as raising :(
        /// </summary>
        /// <returns></returns>
        internal int NumberOpponentsRaisingPreflop()
        {
            int lResult = (int) OhHelper.GetSymbol(Symbols.nopponentsraising);

            if (ctrl.BetTurn == 1 && OhHelper.GetSymbol(Symbols.dealposition) > 2)
            {
                lResult -=  2;
            }

            //Logger.Log(string.Format("Oponents raising preflop: {0}", lResult));

            return lResult;
        }

        protected bool IsInLists(KeyValuePair<string, int> listRange, int fromList)
        {
            bool lResult = false;
            for (int i = fromList; i <= listRange.Value + 1; i++)
            {
                lResult |= Convert.ToBoolean(OhHelper.GetSymbol(string.Format("islist10{0}", i)));
                if (lResult)
                    break;
            }
            return lResult;
        }
    }
}